home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / p063b9s.zip / UNIT / INIT.PAS < prev    next >
Pascal/Delphi Source File  |  1997-03-02  |  23KB  |  707 lines

  1. UNIT Init;
  2. {╔══════════════════════════════════════════════════════════════════════════╗}
  3. {║ Initialization routines                       Last changed: 02.03.97  SA ║}
  4. {║                                                                          ║}
  5. {║                         (C) Copyright 1989-97 by                         ║}
  6. {║       Dan Wulff, Jens Sandalgaard, Steen Christensen & S¢ren Ager        ║}
  7. {║                                                                          ║}
  8. {║ This source may not be given to anybody, without the written permission  ║}
  9. {║ from The Portal Team.                                                    ║}
  10. {╚══════════════════════════════════════════════════════════════════════════╝}
  11. {$I POPDEFS.INC}
  12.  
  13. INTERFACE
  14.  
  15. USES Use32;
  16.  
  17. PROCEDURE InitPortal;
  18.  
  19. IMPLEMENTATION
  20.  
  21. USES Dos, OpCrt, OpString,
  22. {$IFNDEF OS2}
  23.      OpMacro,
  24. {$ENDIF}
  25.      OpDos, OpWindow, OpDate, OpEdit, OpEditor, OpBrowse,
  26.      OpPick, OpMenu, OpEntry, OpFrame, OpAbsFld, OpKey, OpLArray, ApTimer,
  27.      NlComp, Util, Com, Modem, Globals, Config, OproUtil, OutInfo,
  28.      NodeList, FileUtil, Keyboard, LogFile, Display, Event, Resource, NetFile,
  29.      MTask, AreaMan, Session, PoPTypes,BbsDef, List,
  30. {$IFDEF MSGOBJECT}
  31.      PoPEd,
  32. {$ENDIF}
  33. {$IFNDEF OS2}
  34.      Macro,
  35. {$ELSE}
  36.      VpUtils,
  37. {$ENDIF}
  38.      PFix, Input, StrUtil;
  39.  
  40.   PROCEDURE SetupVar;
  41.   BEGIN
  42.     New(OutList, Init);
  43.     New(StatRec);
  44.     CLOutListPtr:=Nil ; FLOutListPtr:=Nil ;
  45.     FillChar(Call, SizeOf(Call), 0);
  46.     MemUsage:=[mu_Upper, mu_EMS, mu_XMS];
  47.     NewTimer(OutboundReRead, 0);
  48.   END;
  49.  
  50.   PROCEDURE ShowRTFM(CONST s: String; MustExit: Boolean);
  51.   VAR
  52.     HelpWin : WindowPtr;
  53.     t       : EventTimer;
  54.   BEGIN
  55.     IF s<>'' THEN WriteLn('Unknown commandline switch: ',s);
  56.     WriteLn;
  57.     WriteLn('PORTAL.EXE [Switches] [CfgFile]');
  58.     WriteLn;
  59.     WriteLn('  /A        Enter AreaMan');
  60.     WriteLn('  /B<Size>  Set extra overlay buffer size');
  61.     WriteLn('  /C        Enter Configuration');
  62.     WriteLn('  /D[U|E|X] Disable Upper, EMS, XMS memory usage');
  63.     WriteLn('  /E        Don''t use XMS or EMS for overlay buffer');
  64. {$IFDEF MSGOBJECT}
  65.     WriteLn('  /F        Enter PoPEd');
  66. {$ENDIF}
  67.     WriteLn('  /H<Path>  Portal homedir');
  68.     WriteLn('  /J        Jump to current event');
  69.     WriteLn('  /M        Turn off macros');
  70. {$IFNDEF NOMAILSCANNER}
  71.     WriteLn('  /M[S|T|P] Perform Mail Scan/Toss/Pack');
  72. {$ENDIF}
  73.     WriteLn('  /N        No-Modem');
  74.     WriteLn('  /O        Check on-line');
  75.     WriteLn('  /Q        Run PoPList (generate filelist)');
  76.     WriteLn('  /R<Secs>  Wait <Secs> before scanning outbound on startup');
  77.     WriteLn('  /T<Task>  Task number');
  78.     WriteLn('  /V        Compile nodelist');
  79.     WriteLn('  /?        Show this help');
  80.     WriteLn;
  81.     WriteLn('  CfgFile   Name of the configuration file to use');
  82.     WriteLn;
  83.     IF NOT MustExit THEN
  84.     BEGIN
  85.       WriteLn;
  86.       WriteLn('Press ESC within 10 seconds to abort Portal');
  87.       WriteLn;
  88.       NewTimerSecs(t, 10);
  89.       WHILE NOT TimerExpired(t) AND NOT KeyPressed DO
  90.         GiveUpTime;
  91.       MustExit:=(KeyPressed) AND (ReadKeyWord=ESC);
  92.     END;
  93.     IF MustExit THEN Halt;
  94.   END;
  95.  
  96.   PROCEDURE ParseCmdLine;
  97.   VAR
  98.     pc,i: Byte;
  99.     Tmp, Param : String;
  100.     x  : Word;
  101.     Ok : Integer;
  102.     Secs : LongInt;
  103.   BEGIN
  104.     Tmp:=StUpCase(GetEnv('POPCMDLINE'));
  105.     FOR i:=1 TO ParamCount DO
  106.       Tmp:=Tmp+' '+StUpCase(ParamStr(i));
  107.     FOR pc:=1 TO WordCount(Tmp, [' ']) DO
  108.     BEGIN
  109.       Param:=ExtractWord(pc, Tmp, [' ']);
  110.  
  111.       IF Param[1] IN ['-','/'] THEN
  112.       BEGIN
  113.         Delete(Param,1,1);
  114.         CASE Param[1] OF
  115.           'A' : CmdLineFlags:=CmdLineFlags OR clAreaMan OR clNoModem;
  116.           'C' : BEGIN
  117.                   CmdLineFlags:=CmdLineFlags OR clNoModem;
  118.                   DoConfig:=1;
  119.                 END;
  120.           'B',
  121.           'E' : ;   { Bruges i OvrlayIn }
  122.           'F' : CmdLineFlags:=CmdLineFlags OR clPoPEd OR clNoModem;
  123.           'D' : FOR i:=2 TO Length(Param) DO
  124.                   CASE Param[i] OF
  125.                     'U' : MemUsage:=MemUsage-[mu_Upper];
  126.                     'E' : BEGIN
  127.                             MemUsage:=MemUsage-[mu_EMS];
  128. {$IFNDEF DPMI}
  129.                             DefaultPriority[2]:=lNoArray;
  130. {$ENDIF}
  131.                           END;
  132.                     'X' : BEGIN
  133.                             MemUsage:=MemUsage-[mu_XMS];
  134. {$IFNDEF DPMI}
  135.   {$IFNDEF OS2}
  136.                             DefaultPriority[3]:=lNoArray;
  137.   {$ENDIF}
  138. {$ENDIF}
  139.                           END;
  140.                     ELSE ShowRTFM('/'+Param, False);
  141.                   END;
  142.           'H' : ChangeDir(Copy(Param, 2, 255));
  143.           'J' : CmdLineFlags:=CmdLineFlags OR clJump2Event;
  144.           'M' : BEGIN
  145.                   IF LENGTH(Param)=1 THEN CmdLineFlags:=CmdLineFlags OR clMacroDefeat ELSE
  146.                   BEGIN
  147. {$IFNDEF NOMAILSCANNER}
  148.                     FOR i:=2 TO LENGTH(param) DO
  149.                       CASE Param[i] OF
  150.                         'S' : CmdLineFlags:=CmdLineFlags OR clMailScan;
  151.                         'T' : CmdLineFlags:=CmdLineFlags OR clMailToss;
  152.                         'P' : CmdLineFlags:=CmdLineFlags OR clMailPack;
  153.                         ELSE ShowRTFM('/'+Param,FALSE);
  154.                       END;
  155. {$ENDIF}
  156.                   END;
  157.                 END;
  158.           'N' : CmdLineFlags:=CmdLineFlags OR clNoModem;
  159.           'O' : CmdLineFlags:=CmdLineFlags OR clCheckOnline;
  160.           'Q' : CmdLineFlags:=CmdLineFlags OR clPoPList OR clNoModem;
  161.           'R' : BEGIN
  162.                   Val(Copy(Param, 2, 255), Secs, Ok);
  163.                   IF Ok=0 THEN
  164.                     NewTimerSecs(OutboundReRead, Secs);
  165.                 END;
  166.           'T' : BEGIN
  167.                   Val(Copy(Param,2,255), i, Ok);
  168.                   IF Ok=0 THEN PoPCfgFileName:='PORTAL'+LongIntForm('@@', i)+'.CFG';
  169.                 END;
  170.           'V' : CmdLineFlags:=CmdLineFlags OR clCompileNL OR clNoModem;
  171.           '?' : ShowRTFM('', True);
  172.           ELSE  ShowRTFM('/'+Param, False);
  173.         END;
  174.       END ELSE
  175.       BEGIN
  176.         IF (Pos('?',Param)>0) Or (Pos('*',Param)>0) THEN
  177.           ShowRTFM(Param, False)
  178.         ELSE
  179.           PoPCfgFileName:=JustFileName(Param);
  180.       END;
  181.     END;
  182.   END;
  183.  
  184.  
  185.   PROCEDURE InitPortal;
  186.   VAR
  187.     EventFile      : TNetFile;
  188.     CopyRight      : WindowPtr;
  189.     o              : Byte;
  190.     Key            : LongInt;
  191.     SkipOutboundScan : Boolean;
  192.  
  193.     PROCEDURE UpdateCallersList;
  194.     TYPE
  195.       LASTCALLrecord = record
  196.         Line           : Byte;
  197.         Name,
  198.         Handle         : S35;
  199.         City           : S25;
  200.         Baud           : Word;
  201.         Times          : LongInt;
  202.         LogOn          : S5;
  203.         LogOff         : S5;
  204.         Attribute      : Byte;
  205.       end;
  206.  
  207.     VAR
  208.       fs:PFileStruct;
  209.       f : TNetFile;
  210.       FPath,FNam:PathStr;
  211.       Buf:POINTER;
  212.       s,ss:STRING;
  213.       Tmp:BYTE;
  214.       l:LONGINT;
  215.  
  216.       PROCEDURE AddUserName(CONST s: S35; FTime: LongInt);
  217.       VAR
  218.         i  : Byte;
  219.         DT : DateTime;
  220.       BEGIN
  221.         IF FTime<>Data.UserTime THEN
  222.         BEGIN
  223.           i:=0;
  224.           REPEAT
  225.             Inc(i);
  226.           UNTIL (i=5) OR (data.users[i].Name='');
  227.           IF (data.users[5].Name<>'') THEN Move(data.users[2],data.users[1],4 * 40);
  228.           data.users[i].Name:=s;
  229.           UnPackTime(FTime,Dt);
  230.           WITH Dt DO
  231.             Data.Users[i].T:=HMSToTime(Hour,Min,Sec);
  232.           Data.UserTime:=FTime;
  233.         END;
  234.       END;
  235.  
  236.     BEGIN
  237.       GetFileStruct(fs,'LASTUSER');
  238.       IF fs<>NIL THEN
  239.       BEGIN
  240.         IF Fs^.Tasks THEN FNam:=MakeTaskFileName(fs^.Name)
  241.                      ELSE FNam:=fs^.Name;
  242.         FPath:=JustPathName(FNam)+'\';
  243.         IF FPath='\' THEN FPath:=Cfg.BBS.Path;
  244.         IF f.Open(FPath+JustFileName(FNam),RecLen(fs),FALSE) THEN
  245.         BEGIN
  246.           GetMem(Buf,RecLen(Fs));
  247.           f.GetRec(Buf^,f.FileSize-1,NoKeep,Wait);
  248.           Tmp:=FindField(Fs,bdName);
  249.           IF Tmp>0 THEN
  250.           BEGIN
  251.             ss:=GetFieldText(fs,Tmp,Buf);
  252.  
  253.             Tmp:=FindField(fs,bdTask);
  254.             IF (Tmp>0) AND (Cfg.TaskNumber>0) THEN
  255.             BEGIN
  256.               GetField(fs,Tmp,Buf,Tmp);
  257.               IF Cfg.TaskNumber<>Tmp THEN Tmp:=0;
  258.             END ELSE Tmp:=1;
  259.             IF Tmp>0 THEN
  260.             BEGIN
  261.               FreeMem(Buf,RecLen(Fs));
  262.               GetFTime(f.f,l);
  263.               f.Close;
  264.               AddUserName(ss,l);
  265.             END;
  266.           END;
  267.         END;
  268.         DisposeFileStruct(fs);
  269.       END;
  270.     END;
  271.  
  272.     PROCEDURE WriteHead;
  273.     VAR
  274.       s : String[80];
  275.     BEGIN
  276.       s:='Portal Of Power v'+Ver;
  277.       IF Cfg.TaskNumber<>0 THEN s:=s+' Task #'+Long2Str(Cfg.TaskNumber);
  278.       TextAttr:=cfg.color[1].TextColor;
  279.       ClrScr;
  280.       FastCenter(s,1,Cfg.Color[1].TextColor);
  281.     END;
  282.  
  283.     PROCEDURE SetupScreen;
  284.     VAR
  285.       Start : Byte;
  286.     BEGIN
  287.       WriteHead;
  288.       FastText('F1=Help   F2=Menu',ScreenHeight-1,2+((ScreenWidth-80) DIV 2));
  289.       FastText('F9=About Today   F10=Edit config',ScreenHeight,48+((ScreenWidth-80) DIV 2));
  290.       MyWin(StatusWindow, 1,2,21,8,1,'Status',False);
  291.       WITH StatusWindow^, Cfg.Color[1] DO
  292.       BEGIN
  293.         wfasttext('Date   :', 1, 2);
  294.         wfasttext('Time   :', 2, 2);
  295.         wfasttext('Event  :', 3, 2);
  296.         wfasttext('Port/Sp:', 4, 2);
  297.         wfasttext('Flags  :', 5, 2);
  298.       END;
  299.       UpdateStatusWindow;
  300.       MyWin(OutBoundWindow, 22,2,80,8,1,'Outbound Packets',False);
  301.       WITH OutboundWindow^ DO
  302.         wfasttext('Destination        S ICDNH R M F  Fls Age  Size TfrTime', 1, 2);
  303.       MyWin(ActivityWindow,1,9,80,ScreenHeight-2-Byte(ScreenHeight>LinesForStat)*7,1,'Activity',False);
  304.       WITH ActivityWindow^.wFrame DO
  305.       BEGIN
  306.         AddHeader(StatusStr,heBR);
  307.         ChangeHeaderAttr(1,Cfg.Color[1].FrameColor,Cfg.Color[1].FrameColor);
  308.         DrawHeader(1);
  309. {$IFDEF UseScrollBars}
  310.         AddScrollBar(FrRR,1,10,Cfg.Color[1]);
  311. {$ENDIF}
  312.         AddHeader(StatusStr,heBL);
  313.         ChangeHeaderAttr(2,Cfg.Color[1].FrameColor,Cfg.Color[1].FrameColor);
  314.         DrawHeader(2);
  315.       END;
  316.       ActivityWindow^.wFrame.SetFrameType(SglWindowFrame);
  317.       OutboundWindow^.wFrame.SetFrameType(DblWindowFrame);
  318.       ActivityWindow^.wFrame.UpDateFrame;
  319.       OutboundWindow^.wFrame.UpDateFrame;
  320.       IF ScreenHeight>LinesForStat THEN
  321.       BEGIN
  322.         MyWin(CallsIn,1,ScreenHeight-8,40,ScreenHeight-2,1,'Last calls in',False);
  323.         UpdateCallsWindow(CallsIn,1);
  324.         MyWin(CallsOut,41,ScreenHeight-8,80,ScreenHeight-2,1,'Last calls out',False);
  325.         UpdateCallsWindow(CallsOut,2);
  326.       END;
  327.       Start:=(ScreenHeight DIV 2)-4;
  328.       MyWin(Copyright,18,Start,62,Start+6,2,'Initializing',True);
  329.       WITH CopyRight^ DO
  330.       BEGIN
  331.         wFastCenter('Portal of Power v'+Ver,2,Cfg.Color[2].TextColor);
  332.         wFastText('(C)  Copyright 1989-97 by The Portal Team',4,2);
  333.       END;
  334.     END;
  335.  
  336.     PROCEDURE GetLogFile;
  337.     VAR
  338.       BufSize,p,fs : LongInt;
  339.       i : Byte;
  340.       Buffer : Array[0..4097] Of Byte;
  341.     BEGIN
  342.       LogLines:=ScreenHeight-12-Byte(ScreenHeight>LinesForStat)*7;
  343.       InLogWin:=False;
  344.       fs:=PortalLog.FileSize; i:=LogLines+1;
  345.       IF fs>4096 THEN BufSize:=4096 ELSE BufSize:=fs;
  346.       PortalLog.Seek(fs-BufSize);
  347.       PortalLog.BlockRead(Buffer,BufSize);
  348.       p:=BufSize+1;
  349.       REPEAT
  350.         REPEAT
  351.           DEC(p);
  352.         UNTIL (p=0) OR (Buffer[p]=10);
  353.         CurrentLogView[i]:=fs-BufSize+p+1;
  354.         Dec(i);
  355.       UNTIL (i=0) or (p=0);
  356.       CurrentLogView[LogLines+1]:=fs+2;
  357.       EndLogView:=CurrentLogView;
  358.       ReWriteLogWindow;
  359.     END;
  360.  
  361.     PROCEDURE ReadControlFile;
  362.     CONST
  363.       NumColors = 31;
  364.     VAR
  365.       f         : FILE OF TConfig;
  366.       f2        : TNetFile;
  367.       fr        : FILE;
  368.       test      : Integer;
  369.       tn,i      : Byte;
  370.       ch        : Char;
  371.       c         : ARRAY[1..4] OF ColorSet;
  372.       ct        : ARRAY[1..4,1..NumColors,1..2] OF BYTE Absolute c;
  373.       x         : TNodeStat;
  374.     BEGIN
  375.       Assign(f, PoPCfgFileName); FileMode:=ShareRead+ShareDenyW;
  376.       Reset(f);
  377.  
  378.       FillChar(cfg,SizeOf(cfg),#0);
  379.       IF IoResult<>0 THEN
  380.       BEGIN
  381.         { Make default configuration file }
  382.         FOR test:=1 TO 4 DO
  383.         BEGIN
  384.           c[test]:=DefaultColorSet;
  385.           IF CurrentMode=BW80 THEN
  386.           BEGIN
  387.             FOR i:=1 TO NumColors DO
  388.               ct[test,i,1]:=ct[test,i,2];
  389.           END ELSE
  390.           BEGIN
  391.             FOR i:=1 TO NumColors DO
  392.               ct[test,i,2]:=ct[test,i,1];
  393.           END;
  394.           Cfg.Color[Test]:=c[Test];
  395.         END;
  396.         WITH cfg DO
  397.         BEGIN
  398.           Version:=CfgVersion;
  399.           LogLevel:=4;
  400.           calltime:=120;
  401.           callwidth:=60;
  402.           BiMail.MaxBaud:=2400;
  403.           BiMail.BiOverride[1]:='/V32';
  404.           ConnectFastest:=True;
  405.           DumbTerm.DestructiveBS:=True;
  406.           UseJanus:=True;
  407.           UseEMSI:=True;
  408.           FastCalls:=True;
  409.           EnterBBSText:='Entering BBS, Fasten seat belts';
  410.           PressESCText:='Press ESC to enter BBS';
  411.           DoingMailText:='Sorry, we''re doing mail at the moment, please call back later';
  412.           OutRereadDelay:=60*60;
  413.           MainAdrNum:=1;
  414.           WITH Screen DO
  415.           BEGIN
  416.             BlankTime:=120;
  417.             HardwareBlank:=False;
  418.             KeepOffScrMode:=True;
  419.           END;
  420.           WITH Modem DO
  421.           BEGIN
  422.             CommPort:=1;
  423.             BaudRate:=2400;
  424.             Init:='|ATZ|~ATS0=0|';
  425.             Dial:='|ATDT';
  426.             PreInit:='|v~^~';
  427.             ReInit:=60*30; { once per 1/2 hour }
  428.             Answer:='~ATA|';
  429.             WaitTime:=60;
  430.           END;
  431.           SwapOnExec:=True;
  432.           FOR x:=nsUnknown TO nsPassword DO
  433.             Inbound[x]:=StartPath+'MAIL\IN\';
  434.           Outbound:=StartPath+'MAIL\OUT';
  435.           LogFileName:=StartPath+PoPLogFileName;
  436.           Nodelist:=StartPath+'NODELIST\';
  437.           Cfg.InboundToDo[nsKnown]:=itd_Tick+itd_File+itd_Mail;
  438.           WITH Packer[1] DO
  439.           BEGIN
  440.             AddCmd:='PKPAK.EXE -oc -a $archive $filespec';
  441.             UnPackCmd:='PKUNPAK.EXE -r $archive $filespec';
  442.             EraseCmd:='PKPAK.EXE d $archive $filespec';
  443.             TestCmd:='PKPAK.EXE t $archive $filespec';
  444.           END;
  445.           WITH Packer[2] DO
  446.           BEGIN
  447.             AddCmd:='PKZIP.EXE -a $archive $filespec';
  448.             UnPackCmd:='PKUNZIP.EXE -e -o $archive $filespec';
  449.             EraseCmd:='PKZIP.EXE -d $archive $filespec';
  450.             TestCmd:='PKUNZIP.EXE -t $archive $filespec';
  451.           END;
  452.           WITH Packer[3] DO
  453.           BEGIN
  454.             AddCmd:='LHARC.EXE a /m $archive $filespec';
  455.             UnPackCmd:='LHARC.EXE e /m $archive $filespec';
  456.             EraseCmd:='LHARC.EXE d /m $archive $filespec';
  457.             TestCmd:='LHARC.EXE t /m $archive $filespec';
  458.           END;
  459.           WITH Packer[4] DO
  460.           BEGIN
  461.             AddCmd:='PAK.EXE a $archive $filespec';
  462.             UnPackCmd:='PAK.EXE e /WA $archive $filespec';
  463.             EraseCmd:='PAK.EXE d $archive $filespec';
  464.             TestCmd:='PAK.EXE t $archive $filespec';
  465.           END;
  466.           WITH Packer[6] DO
  467.           BEGIN
  468.             AddCmd:='SQZ.EXE a -q $archive $filespec';
  469.             UnPackCmd:='SQZ.EXE e $archive $filespec';
  470.             EraseCmd:='SQZ.EXE d $archive $filespec';
  471.             TestCmd:='SQZ.EXE t $archive $filespec';
  472.           END;
  473.           WITH Packer[7] DO
  474.           BEGIN
  475.             AddCmd:='ARJ.EXE a $archive $filespec';
  476.             UnPackCmd:='ARJ.EXE e -y $archive $filespec';
  477.             EraseCmd:='ARJ.EXE d $archive $filespec';
  478.             TestCmd:='ARJ.EXE t $archive $filespec';
  479.           END;
  480.           FOR i:=1 TO 5 DO
  481.           BEGIN
  482.             ExtProt[i].Key:=' ';
  483.             BBS.Multi[i].Key:=' ';
  484.           END;
  485.           WITH AreaMan DO
  486.           BEGIN
  487.             DLCntStart:='[';
  488.             DLCntStop:=']';
  489.           END;
  490.           WITH MailScanner DO
  491.           BEGIN
  492.             DefaultPacker:=1;
  493.           END;
  494.           Request.RspAsPkt:=True;
  495.           KeepEmptyDirs:=(GetDiskClass(Outbound[1], Ch)=NovellDrive);
  496.         END;
  497.         { End of default configuration file }
  498.         DoConfig:=2;
  499.         CmdLineFlags:=CmdLineFlags OR clNoModem;
  500.       END ELSE
  501.       BEGIN
  502.         Read(f,cfg);
  503.         IF IOResult<>0 THEN ;
  504.         Close(f);
  505. {***** Fjernes engang.... *****}
  506.         IF Cfg.Version=2 THEN
  507.         BEGIN
  508.           Cfg.Version:=CfgVersion;
  509.           FOR x:=nsUnknown TO nsPassword DO
  510.             Cfg.Inbound[x]:=Cfg.Filler1;
  511.           Cfg.InboundToDo[nsKnown]:=itd_Tick+itd_File+itd_Mail;
  512.           FillChar(Cfg.Filler1, SizeOf(Cfg.Filler1), 0);
  513.           Cfg.Modem.WaitTime:=60;
  514.           Move(Cfg.Modem.Init[41], Cfg.Modem.NoAnswer, 645);
  515.           SaveConfiguration;
  516.         END;
  517.         IF Cfg.Version=3 THEN
  518.         BEGIN
  519.           Cfg.Version:=CfgVersion;
  520.           Move(Cfg.Modem.Init[41], Cfg.Modem.NoAnswer, 645);
  521.           SaveConfiguration;
  522.         END;
  523.         IF Cfg.Modem.WaitTime=0 THEN Cfg.Modem.WaitTime:=60;
  524. {******************************}
  525.         IF Cfg.Version<>CfgVersion THEN
  526.         BEGIN
  527.           WriteLn('Portal of Power v'+Ver+#10#13'Wrong .CFG-file version - please run CONVCFG.EXE');
  528.           Halt(1);
  529.         END;
  530.       END;
  531.       IF Cfg.HexTask THEN
  532.         Val('$'+Copy(PoPCfgFileName, Pos('.', PoPCfgFileName)-2,2), tn, test)
  533.       ELSE
  534.         Val(Copy(PoPCfgFileName, Pos('.', PoPCfgFileName)-2,2), tn, test);
  535.       IF (Test=0) And (tn<>Cfg.TaskNumber) THEN Cfg.TaskNumber:=tn;
  536.       IF NOT f2.Open(MakeTaskFileName(PoPDataFileName), SizeOf(Data), False) THEN
  537.       BEGIN
  538.         FillChar(data,SizeOf(data),#0);
  539.       END ELSE
  540.       BEGIN
  541.         f2.Read(data,NoKeep,Wait);
  542.         f2.Close;
  543.       END;
  544.       IF NOT f2.Open(MakeTaskFileName(PoPStatisticsFileName), SizeOf(TPortalStat), False) THEN
  545.       BEGIN
  546.         FillChar(StatRec^, SizeOf(StatRec^), 0);
  547.       END ELSE
  548.       BEGIN
  549.         f2.Read(StatRec^,NoKeep,Wait);
  550.         IF f2.IOResult<>0 THEN FillChar(StatRec^, SizeOf(StatRec^), 0);
  551.         f2.Close;
  552.       END;
  553.     END;
  554.  
  555.   BEGIN
  556.     SetupVar;
  557.     CheckBreak:=False;
  558.     UseEnhancedKbd:=EnhancedKbdInstalled;
  559. {$IFNDEF OS2}
  560.     GetCBreak(SaveBreakState);
  561.     SetCBreak(False);
  562. {$ENDIF}
  563.     DetectMultitasking:=True;
  564.     ReInitCrt;
  565.     ParseCmdLine;
  566.     GetDir(0, StartPath);
  567.     IF Copy(StartPath, Length(StartPath), 1)<>'\' THEN StartPath:=StartPath+'\';
  568.     ReadControlFile;
  569.     OldErrPtr:=ExitProc;
  570.     ExitProc:=@ErrorHandler;
  571.     IF NOT Cfg.Screen.KeepOffScrMode THEN SelectFont8x8(Cfg.Screen.ScrMode);
  572.     CheckSnow:=Cfg.Screen.ChkSnow;
  573.     StopClock;
  574.     MenuCommands.SetGetKeyProc(PoPReadKeyWord);
  575.     MenuCommands.SetKeyPressedProc(PoPKeyPressed);
  576.     EntryCommands.SetGetKeyProc(PoPReadKeyWord);
  577.     EntryCommands.SetKeyPressedProc(PoPKeyPressed);
  578.     EditCommands.SetGetKeyProc(PoPReadKeyWord);
  579.     EditCommands.SetKeyPressedProc(PoPKeyPressed);
  580.     PickCommands.SetGetKeyProc(PoPReadKeyWord);
  581.     PickCommands.SetKeyPressedProc(PoPKeyPressed);
  582.     EditorCommands.SetGetKeyProc(PopReadKeyWord);
  583.     EditorCommands.SetKeyPressedProc(PopKeyPressed);
  584.     BrowseCommands.SetKeyPressedProc(PopKeyPressed);
  585.     BrowseCommands.SetGetKeyProc(PopReadKeyWord);
  586.     UserSet1:=['0','1'];
  587.     UserSet2:=['N','Y'];
  588.     ForceCaseUser['1']:=NoChange;
  589.     ForceCaseUser['2']:=UpperCase;
  590.     IF DoConfig<>0 THEN
  591.     BEGIN
  592.       OpenFiles(FALSE);
  593.       WriteHead;
  594.       Key:=-1;
  595.       Configuration(DoConfig=2,Key);
  596.       CloseFiles(FALSE);
  597.       Halt;
  598.     END;
  599.     IF ((CmdLineFlags AND clAreaMan)<>0) THEN
  600.     BEGIN
  601.       OpenFiles(FALSE);
  602.       WriteHead;
  603.       AreaManager;
  604.       CloseFiles(FALSE);
  605.       Halt;
  606.     END;
  607. {$IFDEF MSGOBJECT}
  608.     IF ((CmdLineFlags AND clPoPEd)<>0) THEN
  609.     BEGIN
  610.       OpenFiles(FALSE);
  611.       WriteHead;
  612.       PoPEdMain;
  613.       CloseFiles(FALSE);
  614.       Halt;
  615.     END;
  616. {$ENDIF}
  617.     IF ((CmdLineFlags AND clPoPList)<>0) THEN
  618.     BEGIN
  619.       OpenFiles(FALSE);
  620.       WriteHead;
  621.       ListMain;
  622.       CloseFiles(FALSE);
  623.       Halt;
  624.     END;
  625.     IF ((CmdLineFlags AND clCompileNL)<>0) THEN
  626.     BEGIN
  627.       OpenFiles(FALSE);
  628.       WriteHead;
  629.       CompileNodelist(True);
  630.       CloseFiles(FALSE);
  631.       Halt;
  632.     END;
  633.     IF cfg.logfilename='' THEN
  634.     BEGIN
  635.       WriteLn(^G,'WARNING: No logfile specified...');
  636.       Pause(200);
  637.     END;
  638.     IF (CmdLineFlags AND clNoModem)=0 THEN
  639. {$IFNDEF OS2}
  640.       ComPort:=New(PFossilCom, Init(cfg.Modem.commport))
  641. {$ELSE}
  642.       ComPort:=New(POS2Com, Init(cfg.Modem.commport))
  643. {$ENDIF}
  644.     ELSE
  645.       ComPort:=New(PAbsCom, Init(cfg.Modem.commport));
  646.     IF ComPort=NIL THEN
  647.     BEGIN
  648. {$IFNDEF OS2}
  649.       WriteLn('No FOSSIL loaded - Aborting');
  650. {$ELSE}
  651.       WriteLn('Could not open: COM'+Long2Str(Cfg.Modem.CommPort)+' - Aborting');
  652. {$ENDIF}
  653.       Halt(251);
  654.     END;
  655. {   HiddenCursor;}
  656.     IF (Data.Event<>0) THEN
  657.     BEGIN
  658.       EventFile.Open(StartPath+PoPEventFileName,SizeOf(TEvent),True);
  659.       EventFile.GetRec(CurrentEvent,Data.Event-1,NoKeep,Wait);
  660.       EventFile.Close;
  661.     END ELSE
  662.       FillChar(CurrentEvent, SizeOf(TEvent), 0);
  663.     IF ScreenHeight-12-Byte(ScreenHeight>LinesForStat)*7>=MaxActivityLines THEN
  664.     BEGIN
  665.       WriteLn(^G,'Portal can''t handle more than ', MaxActivityLines+19, ' screenlines');
  666.       Halt(0);
  667.     END;
  668.     SetupScreen;
  669.     OpenFiles(True);
  670.     GetLogFile;
  671.     AddLog('+','Begin, Portal of Power v'+Ver);
  672.     SkipOutboundScan:=PoPKeyPressed;
  673.     WHILE PoPKeyPressed DO PoPReadKeyWord;
  674.     IF NOT ((ComPort^.Carrier OR ComPort^.KeyPressed) AND ((CmdLineFlags AND clCheckOnLine)<>0)) THEN InitModemForEvent;
  675.     IF Data.KbdPassword<>'' THEN
  676.     BEGIN
  677.       KeyboardLock:=True;
  678.       AddLog(' ','Keyboard locked');
  679.     END;
  680. {$IFNDEF OS2}
  681.     IF (Data.MacroStatus) AND ((CmdLineFlags AND clMacroDefeat)=0) THEN MacrosOn;
  682.     WriteMacroStatus;
  683. {$ENDIF}
  684.     InitialiseNodelist(Cfg.NodeList, Cfg.NodelistTyp);
  685.     IF (CurrentEvent.Typ AND etDynamic)=0 THEN ChangeEvent(True);
  686.     IF ((CurrentEvent.Typ AND etUsers)=0) OR (TimerExpired(OutboundReRead) AND NOT SkipOutboundScan)THEN
  687.     BEGIN
  688.       GetOutboundInformation;
  689.       UpdateOutboundWindow;
  690.     END;
  691.     UpdateCallersList;
  692.     IF Data.NextTime.StartTics=0 THEN NewTimerSecs(Data.NextTime, CalculateNextTime) ELSE
  693.       IF TimerExpired(Data.NextTime) THEN NewTimerSecs(Data.NextTime, 15);
  694. {$IFNDEF OS2}
  695.     IF cfg.Defaultmacro<>'' THEN
  696.     BEGIN
  697.       o:=ReadMacroFile(Cfg.DefaultMacro, False);
  698.       IF o<>0 THEN AddLog('!','Error reading macrofile ('+Hexb(o)+')');
  699.     END;
  700. {$ENDIF}
  701.     IF NOT ComPort^.KeyPressed THEN UpdateNetMailFlag;
  702.     StartClock;
  703.     KillWindow(Copyright);
  704.   END;
  705.  
  706. END.
  707.